<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" name="" id="" placeholder="请输入" class="inp1" />
    <button>点击判断</button>
    <input type="text" name="" id="" class="inp2" />
  </body>
</html>
<script>
  var ipt1 = document.querySelector(".inp1");
  var ipt2 = document.querySelector(".inp2");
  var btn = document.querySelector("button");
  btn.onclick = function () {
    if (ipt1.value.trim() == "") return alert("请输入内容");
    if (isNaN(ipt1.value)) {
      ipt2.value = "非数字";
    } else {
      ipt2.value = "是数字";
    }
  };
</script>
